home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00087_Script_MODE Handlers < prev    next >
Text File  |  1996-03-28  |  4KB  |  156 lines

  1. -- --------------------------------------------------------
  2. -- Handler setMode is called when the user clicks on the
  3. -- browser. It sets the mode.
  4.  
  5. on setMode whichMode
  6.   global mode, searchSuccessFul
  7.   
  8.   --  if (mode = "index") or not(searchSuccessFul) then 
  9.   --    -- in search mode but didn't do a find or search was unsuccessful so browser didn't
  10.   --    -- change
  11.   --    setIndexMode
  12.   --  else if (mode = "search") then
  13.   --    setSearchMode
  14.   --  end if
  15.   
  16.   set mode = whichMode
  17. end
  18.  
  19. -- --------------------------------------------------------
  20. -- Handler setIndexMode
  21.  
  22. on setIndexMode
  23.   global browserTopLine, indexButton, searchButton, browserTopics
  24.   global numVisibleTopics, findButton, masterBrowserTopics
  25.   global numLinesPerBrowserEntry, mediaButton
  26.   
  27.   setMode("index")
  28.   setClearedFlag(FALSE)
  29.   
  30.   if isEnabled(indexButton) then -- coming from search mode
  31.     enableButton(searchButton)
  32.     enableButton(mediaButton)
  33.     activateButtonKeepActivated(indexButton)
  34.     disableUserTyping
  35.     clearSearchTopicField
  36.     disableTopicButtons
  37.     disableButton(findButton)
  38.     updatestage
  39.     set browserTopLine = 1
  40.     set browserTopics = the text of cast "browserTopics"
  41.     set masterBrowserTopics = browserTopics
  42.     
  43.     setBrowserText
  44.     setSearchSuccessFul(FALSE)
  45.     
  46.     clearDatabase -- clear it in previous mode
  47.     resetScrollArea
  48.   end if
  49. end
  50.  
  51. -- --------------------------------------------------------
  52. -- Handler setSearchMode 
  53.  
  54. on setSearchMode
  55.   global indexButton, searchButton, inputField, findButton, mediaButton
  56.   
  57.   setMode("search")
  58.   setClearedFlag(FALSE)
  59.   
  60.   if isEnabled(searchButton) then -- coming from index mode
  61.     enableButton(indexButton)
  62.     enableButton(mediaButton)
  63.     activateButtonKeepActivated(searchButton)
  64.     enableButton(findButton)
  65.     disableTopicButtons
  66.     clearDatabase
  67.     enableUserTyping
  68.     setClearedFlag(FALSE)
  69.   end if
  70.   
  71.   removeTopicPicture
  72. end
  73.  
  74. -- --------------------------------------------------------
  75. -- Handler disableUserTyping changes the keyDownScript to
  76. -- process any keyDowns as scrolling for a topic in the 
  77. -- browser and not searching for a topic.
  78.  
  79. on disableUserTyping
  80.   global inputField
  81.   
  82.   set the editableText of sprite inputField = FALSE
  83.   set the keyDownScript = "displayKeyLineAtTop"
  84.   set the keyUpScript = EMPTY
  85. end
  86.  
  87. -- --------------------------------------------------------
  88. -- Handler enableUserTyping changes the keyDownScript to
  89. -- process any keyDowns as searching for a topic in the 
  90. -- browser and not browsing for a topic.
  91.  
  92. on enableUserTyping
  93.   global inputField
  94.   set the keyDownScript = EMPTY
  95.   set the keyUpScript = "checkReturnKey"
  96.   set the editableText of sprite inputField = TRUE
  97. end
  98.  
  99. -- --------------------------------------------------------
  100. -- Handler checkReturnKey makes the return key in search
  101. -- mode behave like clicking the find button.
  102.  
  103. on checkReturnKey
  104.   global browserTopics, numVisibleLines
  105.   
  106.   if (the key = RETURN) then
  107.     -- add ôline 1 of ô to avoid getting RETURN or second line
  108.     set target = line 1 of the text of cast "searchTopic"
  109.     hilite char 1 to 32000 of cast "searchTopic"
  110.     if target = "" then exit
  111.     doFind target
  112.   else
  113.     set charNumber = charToNum(the key)
  114.     set numLines = (the number of lines in browserTopics) - numVisibleLines
  115.     
  116.     if (charNumber = 30) then --  up arrow key
  117.       unhiliteClickedTopic
  118.       scroll(0, -1, numLines)
  119.     else if (charNumber = 31) then -- down arrow key
  120.       unhiliteClickedTopic
  121.       scroll(0, 1, numLines)
  122.     end if
  123.   end if
  124. end
  125.  
  126. -- --------------------------------------------------------
  127. -- Handler setMediaMode sets the mode to media mode
  128.  
  129. on setMediaMode
  130.   global browserTopLine, indexButton, mediaButton, browserTopics
  131.   global findButton, mediaTopics, searchButton
  132.   
  133.   setMode("media")
  134.   
  135.   setClearedFlag(FALSE)
  136.   clearDatabase
  137.   clearSearchTopicField
  138.   
  139.   enableButton(indexButton)
  140.   enableButton(searchButton)
  141.   activateButtonKeepActivated(mediaButton)
  142.   
  143.   disableButton(findButton)
  144.   
  145.   updatestage
  146.   
  147.   set browserTopLine = 1
  148.   setBrowserTopics(mediaTopics)
  149.   setMasterBrowserTopics(browserTopics)
  150.   
  151.   setBrowserText
  152.   
  153.   setSearchSuccessFul(FALSE)
  154.   
  155.   resetScrollArea
  156. end